package	hottargui.standard;

import hottargui.framework.*;

import java.util.*;

/** AlphaGame implementation.
    Presently simply a temporary test stub to be expanded
    by a test-driven process.
 */

public class StandardGame implements Game {

	TarguiState currentState;
	TarguiFactory factory;
	GameObjectServer objectServer;
	
  public StandardGame(TarguiFactory aFactory) {
	  factory = aFactory;
	  objectServer = factory.getGameObjectServer();
	  
	  // initialize state
	  currentState = factory.getNewGameState(this);
  }

  public TarguiFactory getFactory()
  {
	  return factory;
  }

  public GameObjectServer getGameObjectServer() {
	  return objectServer;
  }
  
  public void newGame() {
	  currentState.newGame();
  }

  /** return a specific tile */
  public Tile getTile( Position p ) {
	  List<Tile> boardConf = objectServer.getGameData().getBoardConfiguration();
	  return boardConf.get((p.getRow()*7) + p.getColumn());
  }

  public Player getPlayerInTurn() {
    return objectServer.getGameData().getPlayerInTurn();
  }

  public State getState() {
    return currentState.getState();
  }
  
  public boolean move(Position from, Position to, int count) {
	  return currentState.move(from, to, count);
  }

  public boolean buy(int count, Position deploy) {
	  return currentState.buy(count, deploy);
  }

  public PlayerColor turnCard() {
    return currentState.turnCard();
  }

  public void rollDie() {
	  currentState.rollDie();
  }

  public int getDieValue() {
    return 1;
  }
  
  public void setState(TarguiState newState)
  {
	  this.currentState = newState;
  }
  
  public Iterator<? extends Tile> getBoardIterator() {
    return objectServer.getGameData().getBoardConfiguration().iterator();
  }

  public PlayerColor getWinner()
  {
	  return currentState.getWinner();
  }
  
  public void addGameListener( GameListener observer ) {
  }

  public void report(String s) {
  }

}

